package cn.ywang.concurrent.three;

/**
 * @author BeatificWang
 * @date 2019/7/21 22:49
 */
public class VolatileDemo {
	public volatile static boolean stop = false;

	public static void main(String[] args) throws InterruptedException {
		VolatileDemo demo = new VolatileDemo();
		new Thread(() -> {
			try {
				Thread.sleep(1 * 1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			while (stop) {
				System.out.println("停止运行...");
			}
		}).start();

		VolatileDemo.stop = true;
	}


}
